Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a params parameter to have a generic type #192

Merged
merged 2 commits into from
Nov 23, 2021

Conversation

metoule
Copy link
Contributor

@metoule metoule commented Nov 22, 2021

This is a fix for part of #191. The goal is to allow a params method parameter to be a generic.
Use case:

private static class Utils
{
  public static List<T> Array<T>(params T[] array)
  {
    return new List<T>(array);
  }
}

var target = new Interpreter();
target.Reference(typeof(Utils));

var listInt = target.Eval<List<int>>("Utils.Array(1, 2, 3)");
Assert.AreEqual(new[] { 1, 2, 3 }, listInt);

Previously, the generic type was not promoted from the actual array type.

Copy link
Member

@davideicardi davideicardi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!

@metoule metoule merged commit 0cdc344 into dynamicexpresso:master Nov 23, 2021
@metoule metoule deleted the fix_generic_params_array branch July 23, 2022 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants